Results 1 to 7 of 7

Thread: Attachmodel model to head but change origin

  1. #1
    Purple Developer Purple Elephant1au's Avatar
    Join Date
    Feb 2012
    Location
    Australia
    Posts
    1,259

    Default Attachmodel model to head but change origin

    Hi

    Im trying to spawn a simple cigarette onto a players model on their face , i can get as far as attaching the model to the head so it moves with it , i can change angels , but the model is in the middle of the guys head and cant be seen

    How do attach the model to his head but have it out alittle from the middle and towards his mouth, ive tried a few things ive found round the internet , but none seem to change the position of it.

    Code:
    main:
    while(1)
    {
    setcvar "pe_smoke" ""
    while(getcvar "pe_smoke" == "") {wait 1}
    waitthread get_player
    local.player = $player[level.who] 
    ///local.player attachmodel models/items/cigarette.tik ("Bip01 Head" + ( 20 20 20 ))
    ///local.player attachmodel models/items/cigarette.tik "Bip01 Head" + ( 20 20 20 )
    local.smoke = spawn script_model
    local.smoke model "models/items/cigarette.tik"
    local.smoke.origin = ( 20 20 20 )
    local.smoke notsolid
    local.smoke scale 2
    local.smoke.angles = ( 0 180 20 )
    local.smoke attach local.player "Bip01 Head"
    ////local.smoke attach (local.player "Bip01 Head") + ( 20 20 20 )
    local.player hurt 10
    local.player stufftext ("say Time for a smoke.")
    }
    end
    
    get_player:
    for(level.who = 1;level.who <= $player.size;level.who++) 
    {if($player[level.who].entnum == int(getcvar "pe_smoke"))
    {end}}
    level.who = -1 //no such client
    end
    The one above works to an extent of spawning the model , it moves with the players head , but is stuck in the middle of his head , the lines ///commented // out are things ive seen in different mods around but none seem to work

    Purple's Playground
    OBJ :
    103.29.85.127:12203
    xfire: purpleelephant1au
    email: purpleelephant1au@gmail.com
    skydrive: PurpleElephantSkydrive




  2. #2
    Developer Sor's Avatar
    Join Date
    Aug 2010
    Location
    The Medieval City of Bruges
    Posts
    747

    Default

    Code:
    attachmodel ( String modelname, String tagname, [Float scale], [String targetname], [Boolean detach_at_death], [Float removetime], [Float fadeintime], [Float fadeoutdelay], [Float fadetime], [Vector offset] )    
    
    attach a entity with modelname to this entity to tag called tagname.
    scale - scale of attached entities
    targetname - targetname for attached entities
    detach_at_death - when entity dies, should this model be detached.
    removetime - when the entity should be removed, if not specified, never.
    fadeintime - time to fade the model in over.
    fadeoutdelay - time to wait until we fade the attached model out
    fadeoutspeed - time the model fades out over
    offset - vector offset for the model from the specified tag
    With offset being the missing key. Set this to player.forwardvector * 4 (or another number until you get it right).
    Morpheus Script (MoH) => You try to shoot yourself in the foot only to discover that MorpheusScript already shot your foot for you.

  3. #3
    Purple Developer Purple Elephant1au's Avatar
    Join Date
    Feb 2012
    Location
    Australia
    Posts
    1,259

    Default

    Thanks

    I got it working good , and to turn off when the command is sent again :P now i might just make a trigger for it instead of a cvar so players can walk up to a packet of cigarettes to start smoking :P

    Purple's Playground
    OBJ :
    103.29.85.127:12203
    xfire: purpleelephant1au
    email: purpleelephant1au@gmail.com
    skydrive: PurpleElephantSkydrive




  4. #4
    Developer Sor's Avatar
    Join Date
    Aug 2010
    Location
    The Medieval City of Bruges
    Posts
    747

    Default

    I'm curious, did you quit smoking recently?
    Morpheus Script (MoH) => You try to shoot yourself in the foot only to discover that MorpheusScript already shot your foot for you.

  5. #5
    Purple Developer Purple Elephant1au's Avatar
    Join Date
    Feb 2012
    Location
    Australia
    Posts
    1,259

    Default

    Actually ive never smoked in my life lol Im doing it for a friend who always says brb smoko , so now he can smoke and play :P

    Purple's Playground
    OBJ :
    103.29.85.127:12203
    xfire: purpleelephant1au
    email: purpleelephant1au@gmail.com
    skydrive: PurpleElephantSkydrive




  6. #6

    Default

    Purple, have you checked out these links yet?

    http://www.modtheater.com/threads/smoke-in-moh.32642/
    http://www.modtheater.com/threads/have-a-cigar.35266/

    If you're interested I can attach them mods here.
    Download links on TMT aren't what they used to be, sadly enough...
    -=With One Well Placed Blow Thorin Cleaves Your Skull=-

    http://www.twinbee.org/hob/play.php?snap=hobbit


    <KILL THORIN>
    You attack Thorin.
    But the effort is wasted. His defense is
    too strong.
    Thorin attacks -you- !!!
    With one well placed blow Thorin cleaves
    your skull.
    You are dead.
    You have mastered 0.0% of this adventure.

  7. #7
    Purple Developer Purple Elephant1au's Avatar
    Join Date
    Feb 2012
    Location
    Australia
    Posts
    1,259

    Default

    Thanks for the links , they look cool , the one im doing is more just a learning curve for me atm and something fun to put on my server , not as complex and feature rich as those ones by Viper

    EDIT:

    See here is mine , its alot simpler then vipers , but no bad for me lol still learning, i did just copy his idea of making it global tho adding main local.origin: tho , just learnt that lol

    exec global/smoke.scr ( coords in here )

    Code:
    main local.origin:
    
    local.dish = spawn script_model
    local.dish model "static/dish.tik" //Your ModelPath no /models
    local.dish.origin = local.origin + ( 15 15 40 )
    local.dish.angles = ( 0 45 0 )
    local.dish.scale = 0.7
    
    local.table = spawn script_model
    local.table model "static/tablewithumbrella.tik" //Your ModelPath no /models
    local.table.origin = local.origin
    local.table.angles = ( 0 90 0 )
    local.table.scale = 1
    
    local.smoketrigger = spawn trigger_use origin local.dish.origin
    local.smoketrigger setsize ( -50 -50 -10 ) ( 50 50 50 ) 
    
    while(1)
    {
    local.smoketrigger waittill trigger
    local.player = parm.other
    if(local.player.smoking == 1 )
    
    		{
    			$(smoke) remove
    			local.player stufftext ("say I quit.")
    			local.player fullheal
    			local.player.smoking = 0
    			
    		}
    	else
    		{
    		
    			local.player attachmodel models/items/cigarette.tik "Bip01 Head" 1.5 (smoke) 1 -1 -1 -1 -1 ( 4 7 -1.7 )
    			$(smoke).angles = ( 20 180 10 )
    			///local.player hurt 10
    			local.player stufftext ("say Time for a smoke.")
    			local.player.smoking = 1
    			local.player thread hurt
    			
    		}
    		
    	
    local.smoketrigger notTriggerable
    wait 2
    local.smoketrigger triggerable
    }
    
    		
    end
    
    hurt:
    
    local.player = parm.other
    while(local.player.smoking == 1 )
    {
    	
    	local.player hurt 3
    	wait 10
    
    		if(local.player.health  <= 15)
    	
    			{
    				local.player stufftext ("say Smoking is going to kill me")
    				wait 1 
    			}	
    	
    }
    	 
    	
    end
    So it lets the player walk up to the table and start smoking then has to return to stop smoking lol i think its fun

    Also have one that is controlled via cvar on the player ( enter command again to turn off )
    EDIT: Which now doesnt work .... worked locally but uploaded to server and nope

    Code:
    main:
    while(1)
    {
    setcvar "pe_smoke" ""
    while(getcvar "pe_smoke" == "") {wait 1}
    waitthread get_player
    local.player = $player[level.who] 
    
    
    if(local.player.smoking == 1 )
    
    		{
    			$(local.smoke) remove
    			local.player.smoking = 0
    		}
    	else
    		{
    		
    			local.player attachmodel models/items/cigarette.tik "Bip01 Head" 1.5 (local.smoke) 1 -1 -1 -1 -1 ( 4 7 -1.7 )
    			$(local.smoke).angles = ( 20 180 10 )
    			///local.player hurt 10
    			local.player stufftext ("say Time for a smoke.")
    			local.player.smoking = 1
    		}
    
    }
    end
    
    get_player:
    for(level.who = 1;level.who <= $player.size;level.who++) 
    {if($player[level.who].entnum == int(getcvar "pe_smoke"))
    {end}}
    level.who = -1 //no such client
    end

    Thanks for your help guys
    Last edited by Purple Elephant1au; November 15th, 2012 at 05:18 PM.

    Purple's Playground
    OBJ :
    103.29.85.127:12203
    xfire: purpleelephant1au
    email: purpleelephant1au@gmail.com
    skydrive: PurpleElephantSkydrive




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •